/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.repository.mapper.evaluation;

import cn.ac.nercis.pes.model.dto.evaluation.onsite.EvaluationRecordDTO;
import cn.ac.nercis.pes.repository.model.evaluation.EvaluationRecordDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

/**
 * 测评记录相关信息类型映射
 *
 * @author zpy
 * @version 1.0.0
 */
@Mapper(componentModel = "spring",
        unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface EvaluationRecordMapper {
    EvaluationRecordMapper INSTANCE = Mappers.getMapper(EvaluationRecordMapper.class);

    @Mapping(target = "assetId",source = "asset.id")
    @Mapping(target = "unitTargetId",source = "unitTargetId")
    @Mapping(target = "dResult",expression = "java(entity.getDResult())")
    @Mapping(target = "aResult",expression = "java(entity.getAResult())")
    @Mapping(target = "aCondition", expression = "java(entity.getACondition())")
    @Mapping(target = "kResult",expression = "java(entity.getKResult())")
    @Mapping(target = "kCondition", expression = "java(entity.getKCondition())")
    @Mapping(target = "dContent",expression = "java(entity.getDContent())")
    @Mapping(target = "aContent",expression = "java(entity.getAContent())")
    @Mapping(target = "kContent",expression = "java(entity.getKContent())")
    @Mapping(target = "dFiles",expression = "java(entity.getDFiles())")
    @Mapping(target = "aFiles",expression = "java(entity.getAFiles())")
    @Mapping(target = "kFiles",expression = "java(entity.getKFiles())")
    EvaluationRecordDTO toDTO(EvaluationRecordDO entity);

    @Mapping(target = "dResult",expression = "java(dto.getDResult())")
    @Mapping(target = "aResult",expression = "java(dto.getAResult())")
    @Mapping(target = "aCondition", expression = "java(dto.getACondition())")
    @Mapping(target = "kResult",expression = "java(dto.getKResult())")
    @Mapping(target = "kCondition", expression = "java(dto.getKCondition())")
    @Mapping(target = "dContent",expression = "java(dto.getDContent())")
    @Mapping(target = "aContent",expression = "java(dto.getAContent())")
    @Mapping(target = "kContent",expression = "java(dto.getKContent())")
    @Mapping(target = "dFiles",expression = "java(dto.getDFiles())")
    @Mapping(target = "aFiles",expression = "java(dto.getAFiles())")
    @Mapping(target = "kFiles",expression = "java(dto.getKFiles())")
    EvaluationRecordDO toDO(EvaluationRecordDTO dto);
}